package sys.event;

import sys.database.Database;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SportingEvent {
    String id;
    String name;
    String place;
    String rule;

    public SportingEvent(String id, String name, String place, String rule) {
        this.id = id;
        this.name = name;
        this.place = place;
        this.rule = rule;
    }

    public SportingEvent(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public String getRule() {
        return rule;
    }

    public void setRule(String rule) {
        this.rule = rule;
    }

    /**
     * 查看项目下的所有运动员
     */
    // OK
    public void browserPlayer() {
        String sql = "select * from player where eventID = " + id;
        Database database = new Database();
        Statement stmt = database.createConnection();
        try {
            ResultSet resultSet = stmt.executeQuery(sql);
            System.out.println("该项目下的所有运动员：");
            System.out.println("学/工号" + "   " + "姓名");
            while (resultSet.next()) {
                String playerID = resultSet.getString("playerID");
                String playerName = resultSet.getString("playerName");
                System.out.println(playerID + "     " + playerName);
            }
            } catch (SQLException e) {
                System.out.println("查找失败！");
        }
    }
}
